create or replace view vac_page as
with ap as
(
  select
       application_id,
       page_id,
       application_name,
       page_name,
       page_title,
       media_type,
       tab_set,
       page_alias,
       page_function,
       allow_duplicate_submissions,
       include_apex_css_js_yn,
       focus_cursor,
       header_text,
       body_header,
       footer_text,
       ac_utils.hs(help_text) help_text_hs,
       DBMS_LOB.substr(help_text,4000,      1) help_text_sr1,
       DBMS_LOB.substr(help_text,4000, 4000+1) help_text_sr2,
       DBMS_LOB.substr(help_text,4000, 8000+1) help_text_sr3,
       DBMS_LOB.substr(help_text,4000,12000+1) help_text_sr4,
       page_template,
       authorization_scheme,
       to_char(authorization_scheme_id) authorization_scheme_id,
       build_option,
--
       ac_utils.hs(page_html_header) page_html_header_hs,
       DBMS_LOB.substr(page_html_header,4000,      1) page_html_header_sr1,
       DBMS_LOB.substr(page_html_header,4000, 4000+1) page_html_header_sr2,
       DBMS_LOB.substr(page_html_header,4000, 8000+1) page_html_header_sr3,
       DBMS_LOB.substr(page_html_header,4000,12000+1) page_html_header_sr4,
--
       page_html_onload,
--
       ac_utils.hs(javascript_code_onload)                   javascript_code_onload_hs,
       DBMS_LOB.substr(javascript_code_onload, 4000,      1) javascript_code_onload_sr1,
       DBMS_LOB.substr(javascript_code_onload, 4000, 4000+1) javascript_code_onload_sr2,
       DBMS_LOB.substr(javascript_code_onload, 4000, 8000+1) javascript_code_onload_sr3,
       DBMS_LOB.substr(javascript_code_onload, 4000,12000+1) javascript_code_onload_sr4,
--
       page_requires_authentication,
       page_access_protection,
       page_group, to_char(page_group_id) page_group_id,
       on_dup_submission_goto_url,
       error_notification_text,
       form_autocomplete,
       cached,
       to_char(cache_timeout_seconds) cache_timeout_seconds,
       cached_by_user,
       cache_condition_type,
       cache_condition_exp_1,
       cache_condition_exp_2,
       page_comment,
       to_char(cached_regions) cached_regions
  from apex_application_pages
)
select
       application_id,
       page_id,
       authorization_scheme_id,
       help_text_sr,
       page_html_header_sr,
       javascript_code_onload_sr,
       'APEX_APPLICATION_PAGES' src_view_name,
       U_NAME,
       U_VALUE
from
(
  select application_id,
         page_id,
         authorization_scheme_id,
         to_clob(help_text_sr1)     || to_clob(help_text_sr2)
         ||  to_clob(help_text_sr3) || to_clob(help_text_sr4) help_text_sr,
         to_clob(page_html_header_sr1)    || to_clob(page_html_header_sr2)
         || to_clob(page_html_header_sr3) || to_clob(page_html_header_sr4) page_html_header_sr,
         to_clob(javascript_code_onload_sr1)     || to_clob(javascript_code_onload_sr2)
         || to_clob(javascript_code_onload_sr3)  || to_clob(javascript_code_onload_sr4) javascript_code_onload_sr,
         U_NAME,
         U_VALUE
   from ap
   UNPIVOT INCLUDE NULLS
  ( u_value
     FOR    u_name
     IN
     (   application_name,
         page_name,
         page_title,
         media_type,
         tab_set,
         page_alias,
         page_function,
         allow_duplicate_submissions,
         include_apex_css_js_yn,
         focus_cursor,
         header_text,
         body_header,
         footer_text,
         help_text_hs,
         page_template,
         authorization_scheme,
         build_option,
         page_html_header_hs,
         page_html_onload,
         javascript_code_onload_hs,
         page_requires_authentication,
         page_access_protection,
         page_group,
         page_group_id,
         on_dup_submission_goto_url,
         error_notification_text,
         form_autocomplete,
         cached,
         cache_timeout_seconds,
         cached_by_user,
         cache_condition_type,
         cache_condition_exp_1,
         cache_condition_exp_2,
         page_comment,
         cached_regions
      )
  )
) t;

